
<!DOCTYPE html>
<html lang="en">
<head>
    <script src="/public/js/jquery-3.3.1.min.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>登陆</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        html {
            height: 100%;
            width: 100%;
            overflow: hidden;
            margin: 0;
            padding: 0;
            background: url(/public/img/loginregistBack.png) no-repeat 0px 0px;
            background-repeat: no-repeat;
            background-size: 100% 100%;
            -moz-background-size: 100% 100%;
        }

        body {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100%;
        }a

         #loginDiv {
             width: 37%;
             display: flex;
             justify-content: center;
             align-items: center;
             height: 300px;
             background-color: rgba(75, 81, 95, 0.3);
             box-shadow: 7px 7px 17px rgba(52, 56, 66, 0.5);
             border-radius: 5px;
         }

        #name_trip {
            margin-left: 50px;
            color: red;
        }

        p {
            margin-top: 30px;
            margin-left: 68px;
            color: azure;
        }

        input {
            margin-left: 15px;
            border-radius: 5px;
            border-style: hidden;
            height: 38px;
            width: 250px;
            background-color: rgba(216, 191, 216, 0.5);
            outline: none;
            color: #f0edf3;
            /*padding-left: 10px;*/
        }

        .button {
            border-color: cornsilk;
            background-color: rgba(100, 149, 237, .7);
            color: aliceblue;
            border-style: hidden;
            border-radius: 5px;
            width: 100px;
            height: 31px;
            font-size: 16px;
        }
    </style>

</head>

<body>
<div id="loginDiv">
    <form action="/application/controllers/LoginMatch.php" id="form" method="post">
        <h1 style="text-align: center;color: aliceblue;">登陆</h1>

        <p>用 户 名 :<input id="username" name="username" type="text"><label id="name_trip"></label></p>
        <p>密&nbsp;&ensp;&nbsp;&ensp;码:  <input id="password" name="password" type="password"><label id="password_trip"></label></p>

        <div style="text-align: center;margin-top: 30px;">
            <input type="button" class="button" id="subLogin" name="subLogin" value="登陆">
            <input type="reset" class="button" value="重置">
            <input type="button" class="button" name="findPass" id="findPass" value="找回密码">
        </div>
        <div style="    margin-top: 8px;
    margin-left: 208px;">
            <a style="color: red" href="/index.php?c=Register&a=RegisterFunction">没有账号？点击这里注册哦</a>
        </div>

    </form>
</div>
<script>
    $(function () {
        $("#findPass").on("click",function () {
            $.ajax({
                url:"/index.php?c=Verification&a=seekPass",
                type:"POST",
                data:{
                    username:$("input[name='username']").val()
                },
               dataType:"json",
                success:function (data){
                    console.log(data)
                    if (data.flag){
                        alert(data.msg);
                        location.href="/index.php?c=Login&a=findPass";
                    }else {
                        alert(data.msg);
                    }
                },
                error:function (){
                    alert("请求失败")
                }
            });
        });
    });
    $(function(){
        $("#subLogin").on("click",function(){
            $username = $("input[name='username']").val();
            $password = $("input[name='password']").val();
            if ($username=="" && $password == ""){
                alert("账户密码不能为空");
            }else if ($username==""){
                alert("账户不能为空,请输入");
            }else if ($password == ""){
                alert("密码不能为空,请输入");
            }else {
                $.ajax({
                    url: "/index.php?c=LoginMatch&a=checked",
                    type: "POST",
                    data: {
                        username: $("input[name='username']").val(),
                        password: $("input[name='password']").val()
                    },
                    dataType: "json",
                    success: function (data) {
                        console.log(data)
                        if (data.flag) {
                            alert(data.msg);
                            location.href = "/index";
                        } else {
                            alert(data.msg);
                        }
                    },
                    error: function () {
                        alert("请求失败")
                    }
                });
            }
        });
    });

</script>


</body></html>

